package com.instanceofdemo;

import java.util.Timer;
import java.util.TimerTask;

public class Instanceof {
	public static void main(String[] args) throws InterruptedException {
		
		Base base =new Base();
		final Person person=new Person();
		if(person instanceof Person){
			System.out.println("pp");
		}
		if(person instanceof Base){
			System.out.println("base");
		}
//		person=null;
//		System.gc();
		new Timer().schedule(new TimerTask() {
			
			@Override
			public void run() {
				System.gc();
			}
		}, 0,1000);
		new Timer().schedule(new TimerTask() {
			
			@Override
			public void run() {
				System.out.println(person.age);
			}
		}, 0,1000);
	}
	

}

class Person extends Base{
	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		System.out.println("finalize...");
	}
	public int age=10;
	
}
